package modelcontroller;

/**
 *
 * @author Mariam
 */
public class User {

    private String username;
    private String hostname;

    /**
     * Constructs a new user based on his username and hostname
     *
     * @param username login
     * @param hostname name of his machine
     */
    public User(String username, String hostname) {
        this.username = username;
        this.hostname = hostname;
    }

    /**
     * Gets the login of the user
     *
     * @return the name of the user
     */
    public String getUsername() {
        return username;
    }

    /**
     * Gets the name of the user's machine host
     *
     * @return the hostname of the machine from where is connected the user
     */
    public String getHostname() {
        return hostname;
    }

    @Override
    public String toString() {
        return username + "@" + hostname;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj != null) {
            User u = (User) obj;
            return this.username.equals(u.getUsername());
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 61 * hash + (this.username != null ? this.username.hashCode() : 0);
        return hash;
    }
}
